<!DOCTYPE html>












  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">












<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />






















<link href="/my_blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/my_blog/css/main.css?v=6.3.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/my_blog/images/apple-touch-icon-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/my_blog/images/favicon-32x32-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/my_blog/images/favicon-16x16-next.png?v=6.3.0">


  <link rel="mask-icon" href="/my_blog/images/logo.svg?v=6.3.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/my_blog/',
    scheme: 'Pisces',
    version: '6.3.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="前言从在学校起，一直接触的就是CSharp，算来也有5年的时间了，渐渐觉得自己进入了一个瓶颈。 平时虽然也一直在关注技术，但是总觉得那些新的，很有趣的技术真的很少于CSharp相关，加上工作也是比较封闭的环境，所以想开始学习一门新的语言。 说是学习新的语言，其实“编程语言”只是一个通向广阔技术世界的“桥梁”,我真的想要的是向真正的技术前沿靠近，趁着自己的热血没凉，继续前进，继续开阔眼界。 而选择J">
<meta name="keywords" content="Java,CSharp">
<meta property="og:type" content="article">
<meta property="og:title" content="CSharp to Java #1">
<meta property="og:url" content="http://sdfsd23few23.gitee.io/my_blog/2018/03/12/CSharp-to-Java-1/index.html">
<meta property="og:site_name" content="Raymond&#39;s Blog">
<meta property="og:description" content="前言从在学校起，一直接触的就是CSharp，算来也有5年的时间了，渐渐觉得自己进入了一个瓶颈。 平时虽然也一直在关注技术，但是总觉得那些新的，很有趣的技术真的很少于CSharp相关，加上工作也是比较封闭的环境，所以想开始学习一门新的语言。 说是学习新的语言，其实“编程语言”只是一个通向广阔技术世界的“桥梁”,我真的想要的是向真正的技术前沿靠近，趁着自己的热血没凉，继续前进，继续开阔眼界。 而选择J">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-03-20T15:39:50.322Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="CSharp to Java #1">
<meta name="twitter:description" content="前言从在学校起，一直接触的就是CSharp，算来也有5年的时间了，渐渐觉得自己进入了一个瓶颈。 平时虽然也一直在关注技术，但是总觉得那些新的，很有趣的技术真的很少于CSharp相关，加上工作也是比较封闭的环境，所以想开始学习一门新的语言。 说是学习新的语言，其实“编程语言”只是一个通向广阔技术世界的“桥梁”,我真的想要的是向真正的技术前沿靠近，趁着自己的热血没凉，继续前进，继续开阔眼界。 而选择J">






  <link rel="canonical" href="http://sdfsd23few23.gitee.io/my_blog/2018/03/12/CSharp-to-Java-1/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>CSharp to Java #1 | Raymond's Blog</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/my_blog/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Raymond's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">CSharp & Java</p>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="Toggle navigation bar">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/my_blog/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />Startseite</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/my_blog/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />Tags</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/my_blog/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />Kategorien</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/my_blog/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />Archiv</a>
  </li>

      
      
    </ul>
  

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://sdfsd23few23.gitee.io/my_blog/my_blog/2018/03/12/CSharp-to-Java-1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Raymond">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/my_blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Raymond's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">CSharp to Java #1
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Veröffentlicht am</span>
              

              
                
              

              <time title="Post created: 2018-03-12 21:56:45" itemprop="dateCreated datePublished" datetime="2018-03-12T21:56:45+08:00">2018-03-12</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">Edited on</span>
                
                <time title="Updated at: 2018-03-20 23:39:50" itemprop="dateModified" datetime="2018-03-20T23:39:50+08:00">2018-03-20</time>
              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">in</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/my_blog/categories/Coding/" itemprop="url" rel="index"><span itemprop="name">Coding</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>从在学校起，一直接触的就是CSharp，算来也有5年的时间了，渐渐觉得自己进入了一个瓶颈。</p>
<p>平时虽然也一直在关注技术，但是总觉得那些新的，很有趣的技术真的很少于CSharp相关，加上工作也是比较封闭的环境，所以想开始学习一门新的语言。</p>
<p>说是学习新的语言，其实“编程语言”只是一个通向广阔技术世界的“桥梁”,我真的想要的是向真正的技术前沿靠近，趁着自己的热血没凉，继续前进，继续开阔眼界。</p>
<p>而选择Java也是因为Java与CSharp的十分相似，无论是语言本身还是这门语言的定位。</p>
<p>另外毕业这么久，技术博客也没坚持更新，借这个机会把自己CSharp转Java的过程记录一下。</p>
<h1 id="基础语法"><a href="#基础语法" class="headerlink" title="基础语法"></a>基础语法</h1><p>首先学习一下两个语言的基本语法差别。</p>
<h2 id="方法名称命名规则"><a href="#方法名称命名规则" class="headerlink" title="方法名称命名规则"></a>方法名称命名规则</h2><p>CS:首字母大写。</p>
<p>Java:首字母小写。</p>
<h2 id="源文件名"><a href="#源文件名" class="headerlink" title="源文件名"></a>源文件名</h2><p>Java:源文件名必须和类名相同。当保存文件的时候，你应该使用类名作为文件名保存（切记Java是大小写敏感的），文件名的后缀为.java。（如果文件名和类名不相同则会导致编译错误）。一个源文件中只能有一个public类，可以有多个非public类</p>
<p>CS:没有强制规定，建议一致。</p>
<h2 id="包与命名空间"><a href="#包与命名空间" class="headerlink" title="包与命名空间"></a>包与命名空间</h2><p>Java中包(Package)与CS中的命名空间类似，Java中的default对应CS中的internal。</p>
<h2 id="继承与实现接口的关键字"><a href="#继承与实现接口的关键字" class="headerlink" title="继承与实现接口的关键字"></a>继承与实现接口的关键字</h2><p>java的类继承关键字extends，接口为implements，CS都为’:’</p>
<h2 id="一些其他关键字"><a href="#一些其他关键字" class="headerlink" title="一些其他关键字"></a>一些其他关键字</h2><p>java中的final修饰类表示为封闭类，修饰方法时表示方法不能被重写，修饰变量的时候表示为常量</p>
<p>CS的seal表示封闭类，readonly和const表示常量</p>
<p>在java子类中用supper表示父类，C#用base</p>
<h2 id="String-amp-string"><a href="#String-amp-string" class="headerlink" title="String &amp; string"></a>String &amp; string</h2><h2 id="protected"><a href="#protected" class="headerlink" title="protected"></a>protected</h2><p>Java:同一包内的类和所有子类可见（不能修饰类和接口）<br>CS:包含类或者从包含类派生的类型（不能通过基类访问）</p>

      
    </div>

    

    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/my_blog/tags/Java/" rel="tag"># Java</a>
          
            <a href="/my_blog/tags/CSharp/" rel="tag"># CSharp</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/my_blog/2018/03/12/hello-world/" rel="next" title="Hello World">
                <i class="fa fa-chevron-left"></i> Hello World
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/my_blog/2018/03/14/Java小技巧备忘录/" rel="prev" title="Java小技巧备忘录">
                Java小技巧备忘录 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Inhaltsverzeichnis
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Übersicht
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Raymond</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/my_blog/archives/">
                
                    <span class="site-state-item-count">12</span>
                    <span class="site-state-item-name">Artikel</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/my_blog/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">5</span>
                    <span class="site-state-item-name">Kategorien</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/my_blog/Tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">11</span>
                    <span class="site-state-item-name">Tags</span>
                  </a>
                </div>
              
            </nav>
          

          

          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#基础语法"><span class="nav-number">2.</span> <span class="nav-text">基础语法</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#方法名称命名规则"><span class="nav-number">2.1.</span> <span class="nav-text">方法名称命名规则</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#源文件名"><span class="nav-number">2.2.</span> <span class="nav-text">源文件名</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#包与命名空间"><span class="nav-number">2.3.</span> <span class="nav-text">包与命名空间</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#继承与实现接口的关键字"><span class="nav-number">2.4.</span> <span class="nav-text">继承与实现接口的关键字</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#一些其他关键字"><span class="nav-number">2.5.</span> <span class="nav-text">一些其他关键字</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#String-amp-string"><span class="nav-number">2.6.</span> <span class="nav-text">String &amp; string</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#protected"><span class="nav-number">2.7.</span> <span class="nav-text">protected</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Raymond</span>

  

  
</div>




  <div class="powered-by">Erstellt mit  <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> v3.7.1</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://theme-next.org">NexT.Pisces</a> v6.3.0</div>




        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/my_blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/my_blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/my_blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/my_blog/js/src/utils.js?v=6.3.0"></script>

  <script type="text/javascript" src="/my_blog/js/src/motion.js?v=6.3.0"></script>



  
  


  <script type="text/javascript" src="/my_blog/js/src/affix.js?v=6.3.0"></script>

  <script type="text/javascript" src="/my_blog/js/src/schemes/pisces.js?v=6.3.0"></script>



  
  <script type="text/javascript" src="/my_blog/js/src/scrollspy.js?v=6.3.0"></script>
<script type="text/javascript" src="/my_blog/js/src/post-details.js?v=6.3.0"></script>



  


  <script type="text/javascript" src="/my_blog/js/src/bootstrap.js?v=6.3.0"></script>



  



	





  





  










  





  

  

  

  

  
  

  

  

  

  

  

</body>
</html>
